package algorithm.test;

import java.util.ArrayList;

public class YueSeFuHuan {

	public static void main(String[] args) {
		// TODO �Զ����ɵķ������
		lucky(8, 3);
	}

	public static void lucky(int a, int b) {
		if (a < b) {
			System.out.println("��ʽ����ȷ");
			return;
		}
		ArrayList<Integer> al = new ArrayList<>();
		for (int i = 1; i <= a; i++)
			al.add(i);
		int count = 1;
		for (int i = 0; al.size() != 1; i++) {
			if (i == al.size())
				i = 0;
			if (count % b == 0)
				al.remove(i--);
			count++;
		}
		System.out.println(al.get(0));
	}

}
